﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace PizzaService.BindValidation
{
    /// <summary>
    /// Telefonnummer
    /// </summary>
    class ValidatePhoneNumber : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            string tempS = (string)value;

            foreach (char c in tempS)
            {
                if (!Char.IsDigit(c))
                {
                    if (c == '+')
                        return new ValidationResult(false, "Keine Landesvorwahlen erlaubt");
                    else
                        return new ValidationResult(false, "Keine Sonderzeichen erlaubt");
                }
                    
            }

            return ValidationResult.ValidResult;
        }
    }
}
